package pers.karl.jpa.config;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DBUtil {

    /**
     * 获取数据库连接
     * @return
     * @throws SQLException
     */
    public static Connection getConnection() throws SQLException {
        try {
           DataSource dataSource = (DataSource) SpringUtils.getBean("dataSource");
           return dataSource.getConnection();
        } catch (Exception e){
            throw new SQLException(e);
        }
    }
}
